package com.ycwl.aiLive_2d.controller;

import com.ycwl.aiLive_2d.annotation.IgnoreToken;
import com.ycwl.aiLive_2d.service.GlobalService;
import com.ycwl.aiLive_2d.utils.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/api/AIController/v1")
@Api(tags = "AI")
@Slf4j
public class AIController {

    @Resource
    private GlobalService globalService;

    /**
     * 第一次访问uid传1
     *
     * @param msg
     * @param uid
     * @return
     * @throws IOException
     */
    @GetMapping(value = "/dialogue/{msg}/{uid}")
    @ApiOperation(value = "对话", notes = "第一次访问uid传1")
    @IgnoreToken
    public ApiResponse dialogue(@PathVariable String msg, @PathVariable String uid) {
        return globalService.dialogue(msg, uid);
    }

    @GetMapping(value = "/getMouthList/{uid}")
    @ApiOperation(value = "获取嘴巴弧度数据")
    @IgnoreToken
    public ApiResponse getMouthList(@PathVariable String uid) {
        return globalService.getMouthList(uid);
    }

    @GetMapping(value = "/getAudio/{uid}")
    @ApiOperation(value = "获取语音")
    @IgnoreToken
    public void getAudio(@PathVariable String uid, HttpServletResponse response) {
        globalService.getAudio(response, uid);
    }

}
